tx.begin() cache.put(K,V) // acquire cluster wide lock on K cache.put(K2,V2) // acquire cluster wide lock on K2 cache.put(K,V5) // no-op, we already own cluster wide lock for K tx.commit() // releases locks
Implicit locking goes one step ahead and locks cache keys behind the scene as keys are accessed for modification operations.
Consider a transaction running on one of the cache nodes:
tx.begin() cache.put(K,V) // acquire cluster wide lock on K cache.put(K2,V2) // acquire cluster wide lock on K2 cache.put(K,V5) // no-op, we already own cluster wide lock for K tx.commit() // releases locks
Implicit eager locking locks cache keys across cluster nodes only if it is necessary to do so. In a nutshell, if implicit eager locking is turned on then for each modification Infinispan checks if cache key is locked locally. If it is then a global cluster wide lock has already been obtained, otherwise a cluster wide lock request is sent and lock is acquired.
Implicit eager locking is enabled as follows:
<transaction useEagerLocking="true" />